package com.demo.datastructure.reorder.selectorSort;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

/**
 * @description:
 * @author: ljr
 * @time: 2021/5/8 21:00
 */
public class MySelectorSort5 {


    public static void selectorSort(int[] args, int n){
        for(int i = 0; i < n-1; i++){
            int k = i+1;
            int minIndex = i;
            for(; k < n; k++){
                if(args[minIndex] > args[k]){
                    minIndex = k;
                }
            }

            int min = args[minIndex];
            args[minIndex] = args[i];
            args[i] = min;
        }
    }

    public static void main(String[] args) {
        int[] nums = new int[]{1,2,3,4,6,5};

        Arrays.sort(nums);
        //int[] nums = new int[]{4,5,6,3,4,2,1};
        //MySelectorSort5.selectorSort(nums,nums.length);
        for(int num : nums){
            System.out.println(num);
        }
    }
}
